<template>
  <div>
    <el-table
    height="570"
      v-if="!details"
      :data="tableData"
      style="width: 100%"
      :default-sort="{prop: 'date', order: 'descending'}"
    >
      <el-table-column
        label="申请时间"
        :formatter="formatDate"
        sortable
        width="180">
        <template slot-scope="scope">
          {{scope.row.registerTime|formatTime}}
        </template>
      </el-table-column>
      <el-table-column prop="universityName" label="学校名称" sortable width="180"></el-table-column>
      <el-table-column prop="address" label="学校地址" :formatter="formatter"></el-table-column>
      <el-table-column prop="legalPerson" label="法人" :formatter="formatter2"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click.stop="toDetails(scope.$index, scope.row)">查看详情</el-button>
        </template>
      </el-table-column>


    </el-table>
    <br>
  <div style="float: right;margin-right: 130px;" class="block">
      <el-pagination
      background
      hide-on-single-page
      @current-change="currentChange"
      layout="prev, pager, next"
      :current-page="page.current"
      :total="page.total"></el-pagination>
    </div>
  </div>
</template>

<script>
import { getAppList,getAuditPageList } from "../../network/admin";

export default {
  name: "universityApp",
  data() {
    return {
      // tableData: [],
      details: false,
       page:{

      }
    };
  },
  created() {
    getAppList("university")
      .then(res => {
        console.log(res);
        this.page = res.data.extend.page;
      })
      .catch(err => {
        console.log(err);
      });
  },
  computed: {
    tableData() {
      return this.page.records;
    }
  },
  methods: {
     currentChange(val){
      getAuditPageList('university',val)
      .then(res=>{
        this.page=res.data.extend.page
      })
    },
    toDetails(index, row) {
      console.log("aliwe"+row.uid);
      let id=row.uid
      this.$router.push({
        path: `/admin/detailsU/${id}`
      });
    },
    formatter(row, column) {
      return row.address;
    },
    formatter2(row, column) {
      return row.legalPerson;
    },
    formatDate(row, column) {
      // 获取单元格数据
      let data = row[column.property];
      // if (this.$MyComm.isEmpty(data)) {
      //     return ''
      // }
      let dt = new Date(data);
      return (
        dt.getFullYear() +
        "-" +
        (dt.getMonth() + 1) +
        "-" +
        dt.getDate() +
        " " +
        dt.getHours() +
        ":" +
        dt.getMinutes() +
        ":" +
        dt.getSeconds()
      );
    }
  }
};
</script>

<style scoped>
</style>
